<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>自主招生报名</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name="apple-mobile-web-app-status-bar-style" content="default"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <meta name="format-detection" content="telephone=no"/>
    <link href="${s.base}/mobile/css/weui.min.css" rel="stylesheet" />
    <link href="${s.base}/mobile/css/jquery-weui.css" rel="stylesheet"/>
    <link href="${s.base}/mobile/css/jquery-weui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${s.base}/mobile/css/enrollment/zzzs.css"/>
</head>
<body style="background:#f1f1f1;">
<div class="main-content75" >
    <div id="score-list">
        <!--<div class="data-entry-ctn">
            <div class="data-entry-title data-entry-title-bg"><span>初三成绩1</span></div>
            <div class="div-input-line">
                <label><span class="red">*</span>语文</label>
                <input class="input-chinese" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>数学</label>
                <input class="input-math" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>英语</label>
                <input class="input-english" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>物理</label>
                <input class="input-physics" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>化学</label>
                <input class="input-chemistry" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>政治</label>
                <input class="input-politics" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>历史</label>
                <input class="input-history" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>总分</label>
                <input class="input-count-score" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>班级名次</label>
                <input class="input-class-no" type="number" value="" placeholder="请输入" />
            </div>
            <div class="div-input-line">
                <label><span class="red">*</span>年级名次</label>
                <input class="input-grade-no" type="number" value="" placeholder="请输入" />
            </div>
        </div>-->
    </div>

    <div class="data-list-add" onclick="addScore()"><i class="cyfont">&#xe601;</i>加初三成绩</div>
    <div class="zzzs-btn-ctn mart40">
        <button type="button" onclick="prePage()">上一步</button>
        <button type="button" onclick="nextPage()">下一步</button>
    </div>
</div>
</body>
<script type="text/javascript" src="${s.base}/mobile/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/jquery-weui.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/fontSize.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/common.js"></script>
<script type="text/javascript">
    $(function () {
        var testInfo = '${testInfo}';
        if(isNotBlank(testInfo)){
            var testList = jQuery.parseJSON(testInfo);
            if(testList != null && testList.length >0){
                for (var i =0;i<testList.length;i++){
                    addScore(testList[i]);
                }
            }else{
                addScore(null);
            }
        }else{
            addScore(null);
        }
    });


    function addScore(testObj){
        var chinese = "";
        var math = "";
        var english = "";
        var physics = "";
        var chemistry = "";
        var politics = "";
        var history = "";
        var countScore = "";
        var classNo = "";
        var gradeNo = "";
        if(null != testObj){
            chinese = testObj.chinese;
            math = testObj.math;
            english = testObj.english;
            physics = testObj.physical;
            chemistry = testObj.chemistry;
            politics = testObj.politicial;
            history = testObj.history;
            countScore = testObj.totalScore;
            classNo = testObj.classRank;
            gradeNo = testObj.gradeRank;
        }

        var dataCount = $("#score-list").find(".data-entry-ctn").size();

        var str='<div class="data-entry-ctn">'+
            '<div class="data-entry-title data-entry-title-bg"><span>初三成绩'+(dataCount+1)+'</span>';
            if(dataCount>0){
                str+= '<div class="del-family-list" onclick="delScore(this)"><i class="cyfont">&#xe602;</i></div>';
            }
            str +='</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>语文</label>'+
            '<input class="input-chinese" type="number" value="'+chinese+'" placeholder="请输入" oninput="scoreChange(this);"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>数学</label>'+
            '<input class="input-math" type="number" value="'+math+'" placeholder="请输入" oninput="scoreChange(this);"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>英语</label>'+
            '<input class="input-english" type="number" value="'+english+'" placeholder="请输入" oninput="scoreChange(this);"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>物理</label>'+
            '<input class="input-physics" type="number" value="'+physics+'" placeholder="请输入" oninput="scoreChange(this);"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>化学</label>'+
            '<input class="input-chemistry" type="number" value="'+chemistry+'" placeholder="请输入" oninput="scoreChange(this);"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>政治</label>'+
            '<input class="input-politics" type="number" value="'+politics+'" placeholder="请输入" oninput="scoreChange(this);"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>历史</label>'+
            '<input class="input-history" type="number" value="'+history+'" placeholder="请输入" oninput="scoreChange(this);"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>总分</label>'+
            '<input class="input-count-score" type="number" value="'+countScore+'" placeholder="请输入" readonly="readonly"/>'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>班级名次</label>'+
            '<input class="input-class-no" type="number" value="'+classNo+'" placeholder="请输入" />'+
            '</div>'+
            '<div class="div-input-line">'+
            '<label><span class="red">*</span>年级名次</label>'+
            '<input class="input-grade-no" type="number" value="'+gradeNo+'" placeholder="请输入" />'+
            '</div>'+
            '</div>';
        $("#score-list").append(str);
    }

    function scoreChange(obj){
        var chinese = $(obj).parents(".data-entry-ctn").find(".input-chinese").val();
        var math = $(obj).parents(".data-entry-ctn").find(".input-math").val();
        var english = $(obj).parents(".data-entry-ctn").find(".input-english").val();
        var physics = $(obj).parents(".data-entry-ctn").find(".input-physics").val();
        var chemistry = $(obj).parents(".data-entry-ctn").find(".input-chemistry").val();
        var politics = $(obj).parents(".data-entry-ctn").find(".input-politics").val();
        var history = $(obj).parents(".data-entry-ctn").find(".input-history").val();

        var sumScore = 0;
        if(isNotBlank(chinese)){
            sumScore += parseInt(chinese);
        }
        if(isNotBlank(math)){
            sumScore += parseInt(math);
        }
        if(isNotBlank(english)){
            sumScore += parseInt(english);
        }
        if(isNotBlank(physics)){
            sumScore += parseInt(physics);
        }
        if(isNotBlank(chemistry)){
            sumScore += parseInt(chemistry);
        }
        if(isNotBlank(politics)){
            sumScore += parseInt(politics);
        }
        if(isNotBlank(history)){
            sumScore += parseInt(history);
        }
        $(obj).parents(".data-entry-ctn").find(".input-count-score").val(sumScore);
    }

    function delScore(obj){
        //删除弹窗
        $.confirm("是否确认删除?","温馨提示",
            function () {
                $(obj).parents(".data-entry-ctn").remove();
            },
            function () {
            }
        );

    }

    function nextPage() {
        var testInfo = "[";

        var trueInfo = true;
        $(".data-entry-ctn").each(function(index){
            var title = $(this).find(".data-entry-title span").html();
            var chinese = $(this).find(".input-chinese").val();
            var math = $(this).find(".input-math").val();
            var english = $(this).find(".input-english").val();
            var physics = $(this).find(".input-physics").val();
            var chemistry = $(this).find(".input-chemistry").val();
            var politics = $(this).find(".input-politics").val();
            var history = $(this).find(".input-history").val();
            var countScore = $(this).find(".input-count-score").val();
            var classNo = $(this).find(".input-class-no").val();
            var gradeNo = $(this).find(".input-grade-no").val();

            if(isBlank(chinese)){
                $.toast(title+"的语文成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(math)){
                $.toast(title+"的数学成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(english)){
                $.toast(title+"的英语成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(physics)){
                $.toast(title+"的物理成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(chemistry)){
                $.toast(title+"的化学成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(politics)){
                $.toast(title+"的政治成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(history)){
                $.toast(title+"的历史成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(countScore)){
                $.toast(title+"的总成绩不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(classNo)){
                $.toast(title+"的班级排名不能为空", "text");
                trueInfo = false;
                return false;
            }
            if(isBlank(gradeNo)){
                $.toast(title+"的年级排名不能为空", "text");
                trueInfo = false;
                return false;
            }

            if(index > 0){
                testInfo += ',';
            }
            testInfo += '{"name":"'+title+'","chinese":"'+chinese+'","math":"'+math+'","english":"'+english+
                        '","physical":"'+physics+'","chemistry":"'+chemistry+'","politicial":"'+politics
                +'","history":"'+history+'","totalScore":"'+countScore+'","classRank":"'+classNo+'","gradeRank":"'+gradeNo+'"}';

        });

        if(trueInfo){
            testInfo += ']';
            window.location.href = '/phone/enrollment/infoAward?testInfo='+testInfo+'&releaseId=${releaseId}&token=${token}&applyId=${applyId}';
        }
    }

    function prePage() {
        window.location.href = '/phone/enrollment/infoFamily?releaseId=${releaseId}&token=${token}&applyId=${applyId}';
    }
</script>
</html>
